package com.cy.pj.notice.web.pojo;

/**
 * 基于此对象封装服务器响应到客户端的数据
 * 三部分内容
 * 1:状态码 404, 500
 * 2:消息
 * 3:数据
 */

public class JsonResult {
    //状态码
    private Integer state =1;
    //状态消息
    private String message;
    //数据,一般为查询结果
    private Object data;

    public JsonResult(){}
    public JsonResult(String message){
        this.message=message;
    }
    public JsonResult(Object data){
        this.data=data;
    }
    public JsonResult(Integer state,String message){
        this.state =state;
        this.message = message;
    }
    //当出现异常时,可以通过此构造方法对异常信息进行封装
    public JsonResult (Throwable e){
        this(0,e.getMessage());
    }


    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
